package track

import (
	"github.com/pion/rtcp"
	"time"

	"github.com/pion/rtp"
)

type Track interface {
	UnmarshalFormat(*FormatContext) error // 从sdp中解析数据
	MarshalFormat() *FormatContext        // 构造sdp需要的数据

	CtlParma() *Parma // 参数

	Open()  // 启动(发送者报告, 接收者报告等)
	Close() // 关闭

	ID() int        // 唯一标识
	Codec() CodecId // 编码

	ClockRate() int                                  // 时钟频率
	PTSEqualsDTS(*rtp.Packet) bool                   //
	RtpTimeEncode(t time.Time) (uint32, bool)        // rtp Timestamp
	PacketPTS(pkt *rtp.Packet) (time.Duration, bool) // 获取packet的相对时间
	PacketNTP(pkt *rtp.Packet) (time.Time, bool)     // 获取packet的绝对时间

	Direction() Direction    // 媒体方向
	SSRC() uint32            // ssrc
	PayloadType() uint8      // pt
	RTPMap() string          // a=rtpmap:97 MPEG4-GENERIC/48000/2
	FMTP() map[string]string // a=fmtp:96 streamtype=5;mode=AAC-hbr;sizeLength=13;indexLength=3;indexDeltaLength=3

	WriteRTP(pkt *rtp.Packet) error
	WriteRTCP(packets []rtcp.Packet) error
	WritePacket(t time.Time, data []byte) error

	mustTrack()
}
